﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;

namespace VoirEspaceDisk
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FenetrePrincipale());
        }

        public static void print_info(string path, TextWriter output, int level = 0)
        {
            // liste les fichiers du répertoire courant
            DirectoryInfo di = new DirectoryInfo(path);
            try
            {
                foreach (FileInfo fileinfo in di.GetFiles())
                {
                    for (int i = 0; i < level; i++)
                    {
                        output.Write("-");
                    }
                    output.WriteLine(fileinfo.Name);
                    output.Flush();
                }
            }
            catch (UnauthorizedAccessException uae)
            {
                output.WriteLine("access interdit");
            }
            try
            {
                foreach (DirectoryInfo dossier in di.GetDirectories())
                {
                    for (int i = 0; i < level; i++)
                    {
                        output.Write("-");
                    }
                    output.WriteLine(dossier.Name);
                    output.Flush();
                    print_info(dossier.FullName, output, level + 1);
                }
            }
            catch (UnauthorizedAccessException uae)
            {
                output.WriteLine("access interdit");
            }
        }
    }
}
